﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using Fuse8.ContentManagementFramework.BizFacade;
using Fuse8.ContentManagementFramework.SystemFacade.Globalization;

namespace Fuse8.ContentManagementFramework.Administration.Models
{
    [Serializable]
    public class CmsAdminSearchSnippetModel
    {
            public const string AllAreasItem = "All";

            private IEnumerable<string> allSearchAreas = new string[]{AllAreasItem}.Concat(CmsSearchServiceConfiguration.SearchAreas);

            private IEnumerable<string> _searchAreas;

            public const string EntryText = "Enter Keyword(s)";

            public string SearchQuery { get; set; }

            public IEnumerable<string> SearchAreas
            {
                get { return _searchAreas ?? (_searchAreas = allSearchAreas); }
                set
                {
                    if (value != null)
                    {
                        _searchAreas = value.Contains(AllAreasItem) ? allSearchAreas : value;
                    }
                    else
                    {
                        _searchAreas = allSearchAreas;
                    }
                }
            }

        public IEnumerable<string> AllSearchAreas
        {
            get
            {
                return allSearchAreas;
            }
        }

        private static IGetTextProvider GetTextProvider()
        {
            return GlobalizationFacade.Current.WithDomain("cms_Content", CultureInfo.CurrentUICulture);
        }

        public CmsAdminSearchSnippetModel()
            {
                SearchAreas = AllSearchAreas;
            }

    }
}